package com.hbx.residential_service.service.impl;

import com.github.pagehelper.PageHelper;
import com.hbx.residential_service.dao.ComplaintDao;
import com.hbx.residential_service.domain.Complaint;
import com.hbx.residential_service.service.ComplaintService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class ComplaintServiceImpl implements ComplaintService{
    @Autowired
    private ComplaintDao complaintDao;

    @Override
    public List<Complaint> findAll(int page, int size) {
        PageHelper.startPage(page,size);
        return complaintDao.findAll(page,size);
    }

    @Override
    public Complaint findDetailById(int cpId) {
        return complaintDao.findDetailById(cpId);
    }

    @Override
    public void deleteComplaint(int cpId) {
        complaintDao.deleteComplaint(cpId);
    }

    @Override
    public void UpdateCPById(Complaint complaint) {
        complaintDao.UpdateCPById(complaint);
    }

    @Override
    public List<Complaint> fsByUsername(String content, int page, int size) {
        PageHelper.startPage(page,size);
        return complaintDao.fsByUsername("%"+content+"%",page,size);
    }

    @Override
    public List<Complaint> findByUnHandle(int page, int size) {
        return complaintDao.findByUnHandle(page,size);
    }

}
